package hust.att2.movieticketing;

import hust.att2.fragment.HotFilmFragment;
import hust.att2.fragment.SearchFilmFragment;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.viewpagerindicator.IconPagerAdapter;

class FragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
	protected static final String[] CONTENT = new String[] {
			"Search Film", "Playing", "Upcoming", };
	// protected static final int[] ICONS = new int[] {
	// R.drawable.perm_group_calendar, R.drawable.perm_group_camera,
	// R.drawable.perm_group_device_alarms, R.drawable.perm_group_location };

	private int mCount = CONTENT.length;

	public FragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	@Override
	public Fragment getItem(int position) {
//		if (position == 0)
//			return AccountInfoFragment.newInstance(CONTENT[0]);
		if (position == 0)
			return SearchFilmFragment.newInstance(CONTENT[0]);
		else if (position == 1)
			return HotFilmFragment.newInstance(CONTENT[1]);
		else
			return HotFilmFragment.newInstance(CONTENT[2]);
	}

	@Override
	public int getCount() {
		return mCount;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return FragmentAdapter.CONTENT[position % CONTENT.length];
	}

	public int getIconResId(int index) {
		return 0;// ICONS[index % ICONS.length];
	}

	public void setCount(int count) {
		if (count > 0 && count <= 10) {
			mCount = count;
			notifyDataSetChanged();
		}
	}
}